package com.gl.emms.whale.adapter;

import java.util.HashMap;
import java.util.List;

import com.gl.emms.whale.R;
import com.gl.emms.whale.ui.TabActivity;
import com.gl.emms.whale.util.SystemMsgEntity;

import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 消息ListView的Adapter
 * 
 * @author way
 */
public class SystenMsgViewAdapter extends BaseAdapter {
	private TabActivity context;
	private List<SystemMsgEntity> list;// 消息对象数组
	private LayoutInflater inflater;

	public SystenMsgViewAdapter(TabActivity context, List<SystemMsgEntity> list) {
		this.context = context;
		this.list = list;
		inflater = LayoutInflater.from(context);
	}

	public int getCount() {
		return list.size();
	}

	public Object getItem(int position) {
		return list.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder viewHolder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.item_systemmsg, null);
			viewHolder = new ViewHolder();
			viewHolder.icon = (ImageView) convertView
					.findViewById(R.id.systemMsgimageView_item);
			viewHolder.msgTitle = (TextView) convertView
					.findViewById(R.id.title_item);
			viewHolder.from = (TextView) convertView
					.findViewById(R.id.from_item);
			viewHolder.msgdate = (TextView) convertView
					.findViewById(R.id.time_item);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		if(list.isEmpty())
		{
			
		}else
		{
			SystemMsgEntity entity = list.get(position);
			viewHolder.icon.setImageResource(R.drawable.systemmsg);
			viewHolder.msgTitle.setText(entity.getMsgTitle());
			viewHolder.from.setText(entity.getMsgFrom());
			viewHolder.msgdate.setText(entity.getDate());
		}
		

		return convertView;
	}

	static class ViewHolder {
		public ImageView icon;
		public TextView msgTitle;
		public TextView from;
		public TextView msgdate;

		public boolean isReaded;

	}


}
